//
//  UserDefault.m
//  iOS移动OA
//
//  Created by Zhen Huang on 16/9/27.
//  Copyright © 2016年 黄振. All rights reserved.
//
#import "UserDefault.h"
#import <TMCache.h>
#define kLaunch_Times @"launch_times"
#define kLogin_Data @"user_data"


@implementation UserDefault



// 获取用户信息
+(HOwner *)getUserInfo {
    HOwner *model = [[HOwner alloc]init];
    NSDictionary *dic = [[TMCache sharedCache]objectForKey:kLoginData];
    model.USER_ID = [dic objectForKey:@"USER_ID"];
    model.EMP_ID = [dic objectForKey:@"EMP_ID"];
    model.USER_NAME = [dic objectForKey:@"USER_NAME"];
    model.USER_CODE = [dic objectForKey:@"USER_CODE"];
    model.HOSPITAL_NAME = [dic objectForKey:@"HOSPITAL_NAME"];
    
    if ([model.EMP_ID isEqual:[NSNull null]]) {
        model.EMP_ID = @"-1";
    }
    return model;
    
    }

// 判断是否登录
+(BOOL)isLogin {
    
    NSDictionary *dic = [[TMCache sharedCache]objectForKey:kLoginData];
    NSArray *keyarray = [dic allKeys];
    if (keyarray.count == 0) {
        return NO;

    }
    return YES;


    

}

// 清除用户信息
+ (BOOL)clearUserData {
    
    [[TMCache sharedCache]removeObjectForKey:kLoginData];
    [[TMCache sharedCache]removeObjectForKey:@"deviceToken"];
    [[TMCache sharedCache]removeObjectForKey:@"MENUID"];
    return YES;
}

@end
